<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    <div class="box"></div>
</body>
<script>

    const ipt = document.createElement("input")

    const box = document.querySelector(".box")
    
    // 如果输入框要获取焦点，需要填设置获取焦点属性，然后再插入页面
    // 否则获取焦点无效
    // ipt.autofocus = true;
    
    box.appendChild(ipt);

    console.log(ipt)

    ipt.focus();



    
</script>
</html>